package org.omg.IIOP;

//
// Helper class for : OctetSeq
//
// @author OpenORB Compiler
//
public class OctetSeqHelper
{

	//
	// Insert OctetSeq into an any
	// @param	a an any
	// @param	t OctetSeq value
	//
	public static void insert( org.omg.CORBA.Any a, byte[] t )
	{
		a.insert_Streamable( new org.omg.IIOP.OctetSeqHolder( t ));
	}

	//
	// Extract OctetSeq from an any
	// @param	a an any
	// @return the extracted OctetSeq value
	//
	public static byte[] extract( org.omg.CORBA.Any a )
	{
		return read(a.create_input_stream());
	}

	//
	// Internal TypeCode value
	//
	private static org.omg.CORBA.TypeCode _tc = null;

	//
	// Return the OctetSeq TypeCode
	// @return a TypeCode
	//
	public static org.omg.CORBA.TypeCode type()
	{
		if ( _tc == null ) {
			org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
			_tc = orb.create_alias_tc(id(),"OctetSeq",orb.create_sequence_tc(0,orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_octet)));
		}
		return _tc;
	}

	//
	// Return the OctetSeq IDL ID
	// @return an ID
	//
	public static String id()
	{
		return _id;
	}

	private final static String _id = "IDL:omg.org/IIOP/OctetSeq:1.0";

	//
	// Read OctetSeq from a marshalled stream
	// @param	istream the input stream
	// @return the readed OctetSeq value
	//
	public static byte[] read( org.omg.CORBA.portable.InputStream istream )
	{
		byte[] new_one;
		{
		int size1 = istream.read_ulong();
		new_one = new byte[size1];
		istream.read_octet_array(new_one, 0, new_one.length);
		}

		return new_one;
	}

	//
	// Write OctetSeq into a marshalled stream
	// @param	ostream the output stream
	// @param	value OctetSeq value
	//
	public static void write( org.omg.CORBA.portable.OutputStream ostream, byte[] value )
	{
		ostream.write_ulong(value.length);
		ostream.write_octet_array(value, 0,value.length);
	}

}
